package com.tj.collection.controller.lending.response;

import com.fqgj.common.api.ResponseData;
import com.fqgj.common.utils.StringUtils;
import com.tj.collection.db.entity.ClReceiverDetailEntity;
import com.tj.collection.enums.ClUserContactTypeEnum;

import java.util.ArrayList;
import java.util.List;

/**
 * Author: Karl
 * Date: 2020/12/23 5:06 下午
 */
public class ClEmergencyContactInfoResponse implements ResponseData {

    private List<Item> list = new ArrayList<>();

    public ClEmergencyContactInfoResponse(ClReceiverDetailEntity clReceiverDetailEntity) {
        Item item = null;

        item = new Item().setName("Relative").setValue("Self").setFlag("");
        list.add(item);
        item = new Item().setName("Name").setValue(StringUtils.isNotEmpty(clReceiverDetailEntity.getName()) ? clReceiverDetailEntity.getName() : "--").setFlag("");
        list.add(item);
        item = new Item().setName("Mobile").setValue(StringUtils.isNotEmpty(clReceiverDetailEntity.getMobile()) ? clReceiverDetailEntity.getMobile() : "--").setFlag("");
        list.add(item);

        ClUserContactTypeEnum clUserContactTypeEnum1 = ClUserContactTypeEnum.getEnum(clReceiverDetailEntity.getContact1Relative());
        item = new Item().setName("Contact1 Relative").setValue(clUserContactTypeEnum1 != null ? clUserContactTypeEnum1.getDesc() : "--").setFlag("");
        list.add(item);
        item = new Item().setName("Contact1 Name").setValue(StringUtils.isNotEmpty(clReceiverDetailEntity.getContact1Name()) ? clReceiverDetailEntity.getContact1Name() : "--").setFlag("");
        list.add(item);
        item = new Item().setName("Contact1 Mobile").setValue(StringUtils.isNotEmpty(clReceiverDetailEntity.getContact1Mobile()) ? clReceiverDetailEntity.getContact1Mobile() : "--").setFlag("");
        list.add(item);

        ClUserContactTypeEnum clUserContactTypeEnum2 = ClUserContactTypeEnum.getEnum(clReceiverDetailEntity.getContact2Relative());
        item = new Item().setName("Contact2 Relative").setValue(clUserContactTypeEnum2 != null ? clUserContactTypeEnum2.getDesc() : "--").setFlag("");
        list.add(item);
        item = new Item().setName("Contact2 Name").setValue(StringUtils.isNotEmpty(clReceiverDetailEntity.getContact2Name()) ? clReceiverDetailEntity.getContact2Name() : "--").setFlag("");
        list.add(item);
        item = new Item().setName("Contact2 Mobile").setValue(StringUtils.isNotEmpty(clReceiverDetailEntity.getContact2Mobile()) ? clReceiverDetailEntity.getContact2Mobile() : "--").setFlag("");
        list.add(item);
    }

    public List<Item> getList() {
        return list;
    }

    public ClEmergencyContactInfoResponse setList(List<Item> list) {
        this.list = list;
        return this;
    }

    private static class Item {
        private String name;
        private String value;
        private String flag;

        public String getName() {
            return name;
        }

        public Item setName(String name) {
            this.name = name;
            return this;
        }

        public String getValue() {
            return value;
        }

        public Item setValue(String value) {
            this.value = value;
            return this;
        }

        public String getFlag() {
            return flag;
        }

        public Item setFlag(String flag) {
            this.flag = flag;
            return this;
        }
    }

}
